//
//  ApiConfig.swift
//  PPApp
//
//  Created by xiaopin on 2024/2/28.
//

//MARK: - API环境配置
/// 自定义数据错误编码
let kDataErrorCode = -1
/// 参数传递错误
let kMsgParamsError = "Alert_ParamsError"
/// 服务器数据错误
let kMsgDataError = "Alert_ServerDataError"
/// 服务器没有可加载数据
let kMsgDataEmpty = "Alert_ServerNoData"
/// 无缓存数据
let kMsgNoCacheData = "Alert_NoCache"
/// 服务器数据类型错误，无法正常解析
let kMsgDataConvertError = "Alert_DataConvertError"
/// Socket数据异常，无法正常解析
let kMsgSocketError = "Alert_SocketDataConvertError"
/// 网络已断开，请检查网络重试
let kMsgNetworkClosed = "Alert_NetworkError"
/// 请求超时，请检查网络重试
let kMsgNetworkTimeout = "Alert_NetworkTimeout"
/// 数据解析出现了问题
let kMsgResponseJSONError = "Alert_ResponseJsonError"
/// 网络状态不好，请稍后重试
let kMsgNetworkInterrupt = "Alert_NetworkTimeout"
/// 网络请求失败，请检查网络
let kMsgServerError = "Alert_ServerResError"
/// 检测到您正在使用代理进行非法操作
let kMsgUsedProxy = "检测到您正在使用代理进行非法操作"

let kHostName:String = "api.nnscores.com"
let kRedirectUrl:String = "https://api.nnscores.com"
let kWebDomain:String = "https://m.siwei.com/"
let kFileDomain:String = "https://static.nnscores.com/"
let kFileHost:String = "static.nnscores.com"
let kUniversalLinks:String = "https://api.nnscores.com/"
let kShareDefaultPic:String = "http://static.maoti.com/images/default/nnscores_icon.png"

let kSandboxVerifyURL:String = "https://sandbox.itunes.apple.com/verifyReceipt"
let kAppStoreVerifyURL:String = "https://buy.itunes.apple.com/verifyReceipt"

//更新版本时，全局搜索agreement-html，更新替换写的版本号
let ApiVersion = "v1.4"

//MARK: - API环境
/// 1.正式环境，2,预发布环境(不提供)，3,测试环境(不提供)，4开发环境
let kRunEnv:RunEnv = .develop

let kApiDomain_Release = "https://api.nnscores.com/"
let kApiDomain_Beta = ""
let kApiDomain_Test = ""
let kApiDomain_Delelop = "http://10.0.3.203:8000/"
let kApiDomain_Custom = "http://[IP]:[Port]/"

let kSocket_Release = "wss://api.nnscores.com:2083/conn"
let kSocket_Beta = ""
let kSocket_Test = ""
let kSocket_Delelop = "ws://10.0.4.109:8081/conn"
let kSocket_Custom = "wss://[IP]:[Port]/v3/getConnection"

/// 获取当前运行环境的API地址
/// - Returns: <#description#>
func kApiDomain() -> String{
    if kRunEnv == .release {
        return kApiDomain_Release
    }else if kRunEnv == .beta {
        return kApiDomain_Beta
    }else if kRunEnv == .test {
        return kApiDomain_Test
    }else if kRunEnv == .develop{
        return kApiDomain_Delelop
    }else{
        return kApiDomain_Delelop
    }
}
/// 获取当前运行的Socket地址
/// - Returns: <#description#>
func kSocketURL() -> String{
    if kRunEnv == .release {
        return kSocket_Release
    }else if kRunEnv == .beta {
        return kSocket_Beta
    }else if kRunEnv == .test {
        return kSocket_Test
    }else if kRunEnv == .develop{
        return kSocket_Delelop
    }else {
        return kSocket_Delelop
    }
}

/// 获取当前运行的分享地址
/// - Returns: <#description#>
func kShareLinkUrl() -> String{
    //[name]: detail(文章),person(个人主页),post1(圈子帖子),postItem(话题帖子)，match(赛事)
    //let kShareLinkUrl:String = "https://m.siwei.com/dist/[name].html?id=[id]"
    if kRunEnv == .release {
        return "https://m.siwei.com/dist/[name].html?id=[id]"
    }else if kRunEnv == .beta {
        return "https://m.siwei.com/dist/[name].html?id=[id]&talk=1"
    }else if kRunEnv == .test {
        return "http://m.siwei.com/dist/[name].html?id=[id]&talk=2"
    }else{
        return "http://m.siwei.com/dist/[name].html?id=[id]&talk=3"
    }
}

/// 内容和服务协议地址类型
enum ContentAgreementType:Int {
    /// 关于我们
    case about = 1
    /// 用户使用协议
    case termsofuse = 2
    /// 用户注销协议
    case cancellation = 3
    /// 隐私政策协议文档
    case priavcyPolicy = 4
    /// 免责声明
    case disclaimer = 5
}

/// 获取内容和协议网络地址
/// - Parameter caType: 内容协议类型
/// - Returns: <#description#>
func kContentAgreementUrl(_ caType:ContentAgreementType) -> String{
    if kRunEnv == .release{
        return "\(kApiDomain_Release)agreement/#/\(caType.rawValue)/)"
    }
    return "http://10.0.3.203/agreement/#/\(caType.rawValue)"
}

//MARK: - API请求路径配置
/// API请求路径
enum ApiPath:String {
    //MARK: 公共基础数据模块
    case Common_ReportTimeConsuming = "v1.4/speed_log"
    /// App基础信息
    case Common_AppConfig = "v1.4/site-info"
    /// 引导页图组
    case Common_GuideImages = "v1.4/guide-page"
    /// 获取App版本信息
    case Common_AppVersion = "v1.4/version"
    /// 日志记录
    case Common_Log = "v1.4/err_log"
    // oss信息
    case Common_Oss = "v1.4/common/getsts"
    /// 获取轮播图数据
    case Common_Banners = "v1.4/banners"
    /// 生成分享长图
    case Common_GenerateShareImage = "java/img/photoSharing"
    /// 收藏、点赞(文章、评论、球迷圈、帖子、方案)
    case Common_LikeFavorite = "v1.4/like-or-collection"
    /// 关注、订阅(人、圈子、话题、方案、球队)
    case Common_FollowSubs = "v1.4/follow-on-off"
    /// 广告获取
    case Common_Ad = "v1.4/ad_list"
    /// 广告统计
    case Common_AdStat = "v1.4/event/advertising_choose"
    /// 缓存包列表获取
    case Common_OfflinePackages = "h5/offline/list"
    /// 获取当个缓存包
    case Common_GetPackage = "h5/offline/checked"
    /// 获取语言列表
    case Common_Languages = "v1.4/language_list"
    /// 选择了语言
    case Common_Languages_Changed = "v1.4/sync_lan"
    /// 收藏聚合（v1.3）
    case Common_Favorites = "v1.4/user/operate-collection"
    /// 收藏列表（v1.3）
    case Common_FavoritesList = "v1.4/user/collection/list"
    
    //MARK: 举报拉黑相关模块
    /// 内容举报
    case Common_TipOff = "v1.4/content/tip-off-all"
    /// 拉黑与屏蔽
    case Common_AddBlacklist = "v1.4/blacklist-add"
    /// 拉黑与屏蔽-移除
    case Common_RemoveBlacklist = "v1.4/blacklist-cancel"
    /// 获取黑名单
    case Common_Blacklist = "v1.4/blacklist-list"
    /// 获取侵权举报类型
    case Common_TortTypes = "v1.4/tort/type"
    /// 侵权举报
    case Common_TortReport = "v1.4/tort/report"
    /// 申诉
    case Common_TortAppeal = "v1.4/tort/appeal"
    
    //MARK: 用户模块
    /// 获取用户信息
    case User_Detail = "v1.4/user/userInfo"
    /// 用户绑定设备Token
    case User_BindDeviceToken = "v1.4/device-token"
    /// 未登录用户设备绑定解绑
    case User_VisitorBindDeviceToken = "v1.4/event/device_collection"
    /// 获取游客Token
    case User_VisitorLogin = "v1.4/user_login"
    /// 游客Token更新
    case User_VisitorTokenUpdate = "v1.4/token_update"
    /// 个人主页 --- 用户信息
    case User_PersonalCenterInfo  = "v1.4/user/personal_homepage"
    /// 个人主页 --- 回帖列表（该功能已下线）
    case User_HomPostComments = "v1.4/my-hom-post-comments"
    /// 个人主页 --- 球迷圈列表:  Find_UserFansCircle_List
    /// 用户身份申请状态
    case User_ApplyRoleStatus = "v1.4/user/get-apply-status"
    /// 用户登录
    case User_Login = "v1.4/user/login-all"
    /// 获取验证码
    case User_GetCaptcha = "v1.4/send_sms"
    /// 验证邮箱、手机：找回密码、绑定账号
    case User_Check_Account = "v1.4/safety/account_detection"
    /// 绑定账号
    case User_Bind_Account = "v1.4/safety/account_build"
    /// 密码修改设置：登录密码、支付密码
    case User_Password = "v1.4/safety/password"
    /// 用户资料更新：头像、昵称、简介、性别
    case User_InfoUpdate = "v1.4/user/my-information"

    //MARK: 消息中心模块
    /// 一级会话列表
    case Message_Window = "v1.4/dialogue/window"
    /// 评论助手列表
    case Message_Helper = "v1.4/dialogue/helper"
    /// 消息公告列表
    case Message_NoticeList = "v1.4/tidings/notice-list"
    /// 消息系统消息列表
    case Message_SysNoticeList = "v1.4/tidings/system-notice-list"
    /// 站内信
    case Message_SiteInnerMsg = "v1.4/content/website-info"
    /// 消息公告详情
    case Message_NoticeDetail = "v1.4/tidings/notice-details"
    /// 退出与静音
    case Message_Setup = "v1.4/dialogue/set-up"
    /// 清除单个红点数
    case Message_ClearRedDot = "v1.4/dialogue/red-dot"
    /// 获取单个红点数
    case Message_GetRedDot = "v1.4/dialogue/red-dots"
    
    //MARK: 我的模块
    //MARK: 我的-登录
    /// 登出 改post
    case my_signOut = "v1.4/logout"
    /// 第三方检测
    case my_third_check = "v1.4/checked-third"
    /// 账号合并获取
    case my_acount_mercy = "v1.4/user/account-merge-index"
    /// 账号合并提交
    case my_acount_summit = "v1.4/user/account-merge-handle"
    /// 专家订阅列表和搜索
    case My_SubscribeExpertList = "v1.4/user/expert-list"
    /// 用户的聊球记录
    case My_UserChatRecords = "v1.4/user/ball_chat/list"
    /// 用户关注球队
    case My_FollowTeams = "v1.4/match/follow_team"
    /// 下单支付(购买方案、CZ、TX、DS)
    case My_MakeAndPayOrder = "v1.4/confirm-order"
}
